<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="报名学员" prop="orderStudentName">
        <el-input
          v-model="queryParams.orderStudentName"
          placeholder="请输入报名学员"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报名课程" prop="orderCourse">
        <el-input
          v-model="queryParams.orderCourse"
          placeholder="请输入报名课程"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="经办日期" prop="orderTime">
        <el-input
          v-model="queryParams.orderTime"
          placeholder="请输入经办日期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="购买课时数" prop="orderCourseNumber">
        <el-input
          v-model="queryParams.orderCourseNumber"
          placeholder="请输入购买课时数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="赠送课时数" prop="orderFreecourseNumber">
        <el-input
          v-model="queryParams.orderFreecourseNumber"
          placeholder="请输入赠送课时数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="有效期" prop="orderCourseEndtime">
        <el-input
          v-model="queryParams.orderCourseEndtime"
          placeholder="请输入有效期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="应收金额" prop="amountReceivable">
        <el-input
          v-model="queryParams.amountReceivable"
          placeholder="请输入应收金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="优惠金额" prop="discountAmount">
        <el-input
          v-model="queryParams.discountAmount"
          placeholder="请输入优惠金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实收金额" prop="actualAmountReceived">
        <el-input
          v-model="queryParams.actualAmountReceived"
          placeholder="请输入实收金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="课时总数" prop="totalClassHours">
        <el-input
          v-model="queryParams.totalClassHours"
          placeholder="请输入课时总数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="已消耗课时" prop="consumed">
        <el-input
          v-model="queryParams.consumed"
          placeholder="请输入已消耗课时"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="剩余课时" prop="residue">
        <el-input
          v-model="queryParams.residue"
          placeholder="请输入剩余课时"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注2" prop="orderRemark2">
        <el-input
          v-model="queryParams.orderRemark2"
          placeholder="请输入备注2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注3" prop="orderRemark3">
        <el-input
          v-model="queryParams.orderRemark3"
          placeholder="请输入备注3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注4" prop="orderRemark4">
        <el-input
          v-model="queryParams.orderRemark4"
          placeholder="请输入备注4"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注5" prop="orderRemark5">
        <el-input
          v-model="queryParams.orderRemark5"
          placeholder="请输入备注5"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注6" prop="orderRemark6">
        <el-input
          v-model="queryParams.orderRemark6"
          placeholder="请输入备注6"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注7" prop="orderRemark7">
        <el-input
          v-model="queryParams.orderRemark7"
          placeholder="请输入备注7"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注8" prop="orderRemark8">
        <el-input
          v-model="queryParams.orderRemark8"
          placeholder="请输入备注8"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注9" prop="orderRemark9">
        <el-input
          v-model="queryParams.orderRemark9"
          placeholder="请输入备注9"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注10" prop="orderRemark10">
        <el-input
          v-model="queryParams.orderRemark10"
          placeholder="请输入备注10"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="已确认收入" prop="moneyDetermined">
        <el-input
          v-model="queryParams.moneyDetermined"
          placeholder="请输入已确认收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="未确认收入" prop="moneyUnconfirmed">
        <el-input
          v-model="queryParams.moneyUnconfirmed"
          placeholder="请输入未确认收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="退课数量" prop="droppedClassesNumber">
        <el-input
          v-model="queryParams.droppedClassesNumber"
          placeholder="请输入退课数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="退款总额" prop="moneyDroppedTotal">
        <el-input
          v-model="queryParams.moneyDroppedTotal"
          placeholder="请输入退款总额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="其他费用JSON" prop="otherJson">
        <el-input
          v-model="queryParams.otherJson"
          placeholder="请输入其他费用JSON"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="其他费用总额" prop="moneyOtherTotal">
        <el-input
          v-model="queryParams.moneyOtherTotal"
          placeholder="请输入其他费用总额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单总额(课时费+其他费用)" prop="moneyOrderTotal">
        <el-input
          v-model="queryParams.moneyOrderTotal"
          placeholder="请输入订单总额(课时费+其他费用)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盈亏" prop="profitAndLoss">
        <el-input
          v-model="queryParams.profitAndLoss"
          placeholder="请输入盈亏"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单价" prop="unitPrice">
        <el-input
          v-model="queryParams.unitPrice"
          placeholder="请输入单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="state">
        <el-input
          v-model="queryParams.state"
          placeholder="请输入状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销售人员" prop="saleName">
        <el-input
          v-model="queryParams.saleName"
          placeholder="请输入销售人员"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="机构id" prop="deptId">
        <el-input
          v-model="queryParams.deptId"
          placeholder="请输入机构id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学员id" prop="studentId">
        <el-input
          v-model="queryParams.studentId"
          placeholder="请输入学员id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业绩分配列表ID" prop="saleId">
        <el-input
          v-model="queryParams.saleId"
          placeholder="请输入业绩分配列表ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销售JSON" prop="saleJson">
        <el-input
          v-model="queryParams.saleJson"
          placeholder="请输入销售JSON"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['order:order:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['order:order:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['order:order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['order:order:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="orderId" />
      <el-table-column label="报名学员" align="center" prop="orderStudentName" />
      <el-table-column label="报名课程" align="center" prop="orderCourse" />
      <el-table-column label="经办日期" align="center" prop="orderTime" />
      <el-table-column label="购课类型" align="center" prop="orderType" />
      <el-table-column label="购买课时数" align="center" prop="orderCourseNumber" />
      <el-table-column label="赠送课时数" align="center" prop="orderFreecourseNumber" />
      <el-table-column label="有效期" align="center" prop="orderCourseEndtime" />
      <el-table-column label="应收金额" align="center" prop="amountReceivable" />
      <el-table-column label="优惠金额" align="center" prop="discountAmount" />
      <el-table-column label="实收金额" align="center" prop="actualAmountReceived" />
      <el-table-column label="课时总数" align="center" prop="totalClassHours" />
      <el-table-column label="已消耗课时" align="center" prop="consumed" />
      <el-table-column label="剩余课时" align="center" prop="residue" />
      <el-table-column label="备注" align="center" prop="orderRemark" />
      <el-table-column label="备注2" align="center" prop="orderRemark2" />
      <el-table-column label="备注3" align="center" prop="orderRemark3" />
      <el-table-column label="备注4" align="center" prop="orderRemark4" />
      <el-table-column label="备注5" align="center" prop="orderRemark5" />
      <el-table-column label="备注6" align="center" prop="orderRemark6" />
      <el-table-column label="备注7" align="center" prop="orderRemark7" />
      <el-table-column label="备注8" align="center" prop="orderRemark8" />
      <el-table-column label="备注9" align="center" prop="orderRemark9" />
      <el-table-column label="备注10" align="center" prop="orderRemark10" />
      <el-table-column label="已确认收入" align="center" prop="moneyDetermined" />
      <el-table-column label="未确认收入" align="center" prop="moneyUnconfirmed" />
      <el-table-column label="退课数量" align="center" prop="droppedClassesNumber" />
      <el-table-column label="退款总额" align="center" prop="moneyDroppedTotal" />
      <el-table-column label="其他费用JSON" align="center" prop="otherJson" />
      <el-table-column label="其他费用总额" align="center" prop="moneyOtherTotal" />
      <el-table-column label="订单总额(课时费+其他费用)" align="center" prop="moneyOrderTotal" />
      <el-table-column label="盈亏" align="center" prop="profitAndLoss" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="单位" align="center" prop="unit" />
      <el-table-column label="状态" align="center" prop="state" />
      <el-table-column label="销售人员" align="center" prop="saleName" />
      <el-table-column label="机构id" align="center" prop="deptId" />
      <el-table-column label="学员id" align="center" prop="studentId" />
      <el-table-column label="业绩分配列表ID" align="center" prop="saleId" />
      <el-table-column label="销售JSON" align="center" prop="saleJson" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['order:order:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['order:order:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="报名学员" prop="orderStudentName">
          <el-input v-model="form.orderStudentName" placeholder="请输入报名学员" />
        </el-form-item>
        <el-form-item label="报名课程" prop="orderCourse">
          <el-input v-model="form.orderCourse" placeholder="请输入报名课程" />
        </el-form-item>
        <el-form-item label="经办日期" prop="orderTime">
          <el-input v-model="form.orderTime" placeholder="请输入经办日期" />
        </el-form-item>
        <el-form-item label="购买课时数" prop="orderCourseNumber">
          <el-input v-model="form.orderCourseNumber" placeholder="请输入购买课时数" />
        </el-form-item>
        <el-form-item label="赠送课时数" prop="orderFreecourseNumber">
          <el-input v-model="form.orderFreecourseNumber" placeholder="请输入赠送课时数" />
        </el-form-item>
        <el-form-item label="有效期" prop="orderCourseEndtime">
          <el-input v-model="form.orderCourseEndtime" placeholder="请输入有效期" />
        </el-form-item>
        <el-form-item label="应收金额" prop="amountReceivable">
          <el-input v-model="form.amountReceivable" placeholder="请输入应收金额" />
        </el-form-item>
        <el-form-item label="优惠金额" prop="discountAmount">
          <el-input v-model="form.discountAmount" placeholder="请输入优惠金额" />
        </el-form-item>
        <el-form-item label="实收金额" prop="actualAmountReceived">
          <el-input v-model="form.actualAmountReceived" placeholder="请输入实收金额" />
        </el-form-item>
        <el-form-item label="课时总数" prop="totalClassHours">
          <el-input v-model="form.totalClassHours" placeholder="请输入课时总数" />
        </el-form-item>
        <el-form-item label="已消耗课时" prop="consumed">
          <el-input v-model="form.consumed" placeholder="请输入已消耗课时" />
        </el-form-item>
        <el-form-item label="剩余课时" prop="residue">
          <el-input v-model="form.residue" placeholder="请输入剩余课时" />
        </el-form-item>
        <el-form-item label="删除标志" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
        </el-form-item>
        <el-form-item label="备注" prop="orderRemark">
          <el-input v-model="form.orderRemark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注2" prop="orderRemark2">
          <el-input v-model="form.orderRemark2" placeholder="请输入备注2" />
        </el-form-item>
        <el-form-item label="备注3" prop="orderRemark3">
          <el-input v-model="form.orderRemark3" placeholder="请输入备注3" />
        </el-form-item>
        <el-form-item label="备注4" prop="orderRemark4">
          <el-input v-model="form.orderRemark4" placeholder="请输入备注4" />
        </el-form-item>
        <el-form-item label="备注5" prop="orderRemark5">
          <el-input v-model="form.orderRemark5" placeholder="请输入备注5" />
        </el-form-item>
        <el-form-item label="备注6" prop="orderRemark6">
          <el-input v-model="form.orderRemark6" placeholder="请输入备注6" />
        </el-form-item>
        <el-form-item label="备注7" prop="orderRemark7">
          <el-input v-model="form.orderRemark7" placeholder="请输入备注7" />
        </el-form-item>
        <el-form-item label="备注8" prop="orderRemark8">
          <el-input v-model="form.orderRemark8" placeholder="请输入备注8" />
        </el-form-item>
        <el-form-item label="备注9" prop="orderRemark9">
          <el-input v-model="form.orderRemark9" placeholder="请输入备注9" />
        </el-form-item>
        <el-form-item label="备注10" prop="orderRemark10">
          <el-input v-model="form.orderRemark10" placeholder="请输入备注10" />
        </el-form-item>
        <el-form-item label="已确认收入" prop="moneyDetermined">
          <el-input v-model="form.moneyDetermined" placeholder="请输入已确认收入" />
        </el-form-item>
        <el-form-item label="未确认收入" prop="moneyUnconfirmed">
          <el-input v-model="form.moneyUnconfirmed" placeholder="请输入未确认收入" />
        </el-form-item>
        <el-form-item label="退课数量" prop="droppedClassesNumber">
          <el-input v-model="form.droppedClassesNumber" placeholder="请输入退课数量" />
        </el-form-item>
        <el-form-item label="退款总额" prop="moneyDroppedTotal">
          <el-input v-model="form.moneyDroppedTotal" placeholder="请输入退款总额" />
        </el-form-item>
        <el-form-item label="其他费用JSON" prop="otherJson">
          <el-input v-model="form.otherJson" placeholder="请输入其他费用JSON" />
        </el-form-item>
        <el-form-item label="其他费用总额" prop="moneyOtherTotal">
          <el-input v-model="form.moneyOtherTotal" placeholder="请输入其他费用总额" />
        </el-form-item>
        <el-form-item label="订单总额(课时费+其他费用)" prop="moneyOrderTotal">
          <el-input v-model="form.moneyOrderTotal" placeholder="请输入订单总额(课时费+其他费用)" />
        </el-form-item>
        <el-form-item label="盈亏" prop="profitAndLoss">
          <el-input v-model="form.profitAndLoss" placeholder="请输入盈亏" />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input v-model="form.unitPrice" placeholder="请输入单价" />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="状态" prop="state">
          <el-input v-model="form.state" placeholder="请输入状态" />
        </el-form-item>
        <el-form-item label="销售人员" prop="saleName">
          <el-input v-model="form.saleName" placeholder="请输入销售人员" />
        </el-form-item>
        <el-form-item label="机构id" prop="deptId">
          <el-input v-model="form.deptId" placeholder="请输入机构id" />
        </el-form-item>
        <el-form-item label="学员id" prop="studentId">
          <el-input v-model="form.studentId" placeholder="请输入学员id" />
        </el-form-item>
        <el-form-item label="业绩分配列表ID" prop="saleId">
          <el-input v-model="form.saleId" placeholder="请输入业绩分配列表ID" />
        </el-form-item>
        <el-form-item label="销售JSON" prop="saleJson">
          <el-input v-model="form.saleJson" placeholder="请输入销售JSON" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listOrder, getOrder, delOrder, addOrder, updateOrder } from "@/api/order/order";

export default {
  name: "Order",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单表格数据
      orderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderStudentName: null,
        orderCourse: null,
        orderTime: null,
        orderType: null,
        orderCourseNumber: null,
        orderFreecourseNumber: null,
        orderCourseEndtime: null,
        amountReceivable: null,
        discountAmount: null,
        actualAmountReceived: null,
        totalClassHours: null,
        consumed: null,
        residue: null,
        orderRemark: null,
        orderRemark2: null,
        orderRemark3: null,
        orderRemark4: null,
        orderRemark5: null,
        orderRemark6: null,
        orderRemark7: null,
        orderRemark8: null,
        orderRemark9: null,
        orderRemark10: null,
        moneyDetermined: null,
        moneyUnconfirmed: null,
        droppedClassesNumber: null,
        moneyDroppedTotal: null,
        otherJson: null,
        moneyOtherTotal: null,
        moneyOrderTotal: null,
        profitAndLoss: null,
        unitPrice: null,
        unit: null,
        state: null,
        saleName: null,
        deptId: null,
        studentId: null,
        saleId: null,
        saleJson: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询订单列表 */
    getList() {
      this.loading = true;
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        orderStudentName: null,
        orderCourse: null,
        orderTime: null,
        orderType: null,
        orderCourseNumber: null,
        orderFreecourseNumber: null,
        orderCourseEndtime: null,
        amountReceivable: null,
        discountAmount: null,
        actualAmountReceived: null,
        totalClassHours: null,
        consumed: null,
        residue: null,
        delFlag: null,
        createTime: null,
        createBy: null,
        updateBy: null,
        updateTime: null,
        orderRemark: null,
        orderRemark2: null,
        orderRemark3: null,
        orderRemark4: null,
        orderRemark5: null,
        orderRemark6: null,
        orderRemark7: null,
        orderRemark8: null,
        orderRemark9: null,
        orderRemark10: null,
        moneyDetermined: null,
        moneyUnconfirmed: null,
        droppedClassesNumber: null,
        moneyDroppedTotal: null,
        otherJson: null,
        moneyOtherTotal: null,
        moneyOrderTotal: null,
        profitAndLoss: null,
        unitPrice: null,
        unit: null,
        state: null,
        saleName: null,
        deptId: null,
        studentId: null,
        saleId: null,
        saleJson: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加订单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const orderId = row.orderId || this.ids
      getOrder(orderId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改订单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.orderId != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orderIds = row.orderId || this.ids;
      this.$modal.confirm('是否确认删除订单编号为"' + orderIds + '"的数据项？').then(function() {
        return delOrder(orderIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('order/order/export', {
        ...this.queryParams
      }, `order_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
